package edu.rit.drh4818.fire.data;

import java.util.Random;



/**
 * Simple data uses data point directly below it.
 * 
 * @author Darren Headrick
 *
 */
public class SimpleFuelData extends EmitterVolume
{
	public static String NAME = "Simple";
	private static final int DIMENSION = 50;
	
	public SimpleFuelData()
	{
		super( DIMENSION, true, NAME );
	}
	
	public void update() 
	{
		if( volData == null ) return;
		Random r = new Random();
		
		short[][][] tmp = new short[ DIMENSION ][ DIMENSION ][ DIMENSION ];
		
		for( int y = DIMENSION-1; y > 0; y-- )
		{
			for( int x = 0; x < DIMENSION; x++ )
			{
				for( int z = 0; z < DIMENSION; z++ )
				{
					if( volData[x][y-1][z] != 0 )
					{
						tmp[x][y][z] = (short)(volData[x][y-1][z] + r.nextInt(20));
						if( tmp[x][y][z] >= 255 ) tmp[x][y][z] = 0;
					}
				}
			}
		}
		
		volData = tmp;
		super.update();

		generateTexture();
	}
}
